package lookie.swing.laf;

import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class InstalledLookAndFeelDescriptorContributor implements
		LookAndFeelDescriptorContributor {

	private Logger logger = LoggerFactory
			.getLogger(InstalledLookAndFeelDescriptorContributor.class);

	public void contribute(LookAndFeelRegistry registry) {
		for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
			if (logger.isDebugEnabled()) {
				logger.debug(String.format(
						"adding lnf %s to group 'installed'",
						new Object[] { info.getClassName() }));
			}
			DefaultLookAndFeelDescriptor descriptor = new DefaultLookAndFeelDescriptor();
			descriptor.setClassName(info.getClassName());
			descriptor.setName(info.getName());
			descriptor.setGroupId("installed");
			descriptor.setId("installed." + info.getName());
			registry.addDescriptor(descriptor);
		}

	}

}
